package cn.adviceclient.event;

import cn.adviceclient.event.impl.*;
import cn.adviceclient.features.module.Module;
import cn.adviceclient.features.module.ModuleManager;

import static cn.adviceclient.features.module.ModuleManager.modules;

public class EventManager {
    public static void initialize() {
        EventBus.register(new EventManager());
    }

    @Listener
    public void onTick(TickEvent event) {
        for (Module module : ModuleManager.getModules()) {
            if (module.getEnabled()) {
                module.onTick();
            }
        }
    }

    @Listener
    public void onRender2D(Render2DEvent event) {
        for (Module module : ModuleManager.getModules()) {
            if (module.getEnabled()) {
                module.onRender2D(event);
            }
        }
    }

    @Listener
    public void onRender3D(Render3DEvent event) {
        for (Module module : ModuleManager.getModules()) {
            if (module.getEnabled()) {
                module.onRender3D(event);
            }
        }
    }

    @Listener
    public void onKey(KeyboardEvent event) {
        for (Module module : modules) {
            if (module.getKey() == event.getKey()) {
                module.toggle();
            }
        }
    }
}